import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.swing.*;
import javax.xml.ws.handler.MessageContext.Scope;
public class CMain extends JFrame implements WindowListener, ActionListener{
	
	private JPanel pane;
	private JButton jbutton1;
	private ImageIcon image;
	private JScrollPane jscrollpane;
	private ImageBackgroundPanel imagePane;
	public CMain(String sTitle)
	{
		super(sTitle);
		addWindowListener(this);
		pane = new JPanel();
		image= new ImageIcon("F:\\1.jpg");
		imagePane = new ImageBackgroundPanel(image.getImage());
		//this.add(imagePane);
	
		jbutton1 = new JButton("OK");
		imagePane.add(jbutton1);
		jscrollpane = new JScrollPane(imagePane);
		setContentPane(jscrollpane);
		
		
		this.setSize(400, 400);
		this.setVisible(true);
		
	}
	/**
	 * @param args
	 */
	
		public static void main(String[] args) throws IOException {
	      CMain cmain= new CMain("Bui yen Binh");
	    }
	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		JOptionPane oPane = new JOptionPane();
		oPane.showMessageDialog(this, "sfsfd");
		
	}

}
class ImageBackgroundPanel extends JPanel {
    Image image;
    Dimension size= new Dimension();
 
    ImageBackgroundPanel(Image image) {
    	size= this.getSize();
        this.image = image;
      
        
    }
 
    protected void paintComponent(Graphics g) {
    	
    	
        g.drawImage(image, 0,0 ,getHeight(),getWidth(), this);
        setOpaque(false);
        super.paintComponent(g);
    }
}